/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bgp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author rpathan
 */
public class General {

    private Integer ID;
    private String type;
    private Map<Integer,ArrayList<Message>> receivedMessages;

    public General(Integer ID, String type) {
        this.ID = ID;
        this.type = type;
        receivedMessages = new HashMap<Integer,ArrayList<Message>>();
    }

    public int getID() {
        return ID;
    }

    public String getType() {
        return type;
    }

    public void addMessage(Integer round, Message message) {

        if (receivedMessages.containsKey(round)) {
            receivedMessages.get(round).add(message);
        } else {
            ArrayList<Message> roundMessages = new ArrayList<Message>();
            roundMessages.add(message);
            receivedMessages.put(round, roundMessages);
        }
    }

    public ArrayList<Message> getReceivedMessages(Integer round) {

        return receivedMessages.get(round);
    }

    @Override
    public String toString() {
        return ID.toString() + " " + type;
    }
}
